package cn.wolfcode.mapper;

import cn.wolfcode.domain.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookMapper {
    @Insert("""
            
            insert into t_books (bname, author, salePrice, costPrice, classify) values (
              #{bname},                                                                        
              #{author},                                                                        
              #{salePrice},                                                                        
              #{costPrice},                                                                        
              #{classify}                                                                                                 
            );""")
    void add(Book book);
@Update("""
        update t_books set 
         bname=#{bname},                  
         author=#{author},                  
         salePrice=#{salePrice},                  
        costPrice=#{costPrice},                  
         classify=#{classify}
                                                    where id=#{id}
        """)
    void update(Book book);
@Delete("""
        delete from t_books 
               where id=#{id}
        """)
    void delById(Long id);
@Select("""
                select id, bname, author, salePrice, costPrice, classify
                from t_books
                where id=#{id}
""")
    Book getById(Long id);
    @Select("""
                select id, bname, author, salePrice, costPrice, classify
                from t_books
""")
    List<Book> getAll();
}
